package com.wyh.lease;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @ClassName AdminWebApplication
 * @Description TODO
 * @Author xxx
 * @Date 2025/8/11 10:40
 */

@SpringBootApplication
public class AdminWebApplication {
    public static void main(String[] args) {
        SpringApplication.run(AdminWebApplication.class, args);
    }

    @Bean
    public static BeanFactoryPostProcessor beanFactoryPostProcessor() {
        return new BeanFactoryPostProcessor() {
            @Override
            public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
                // 移除问题Bean定义
                if (beanFactory.containsBeanDefinition("ddlApplicationRunner")) {
                    // 真正移除Bean定义
                    ((DefaultListableBeanFactory) beanFactory).removeBeanDefinition("ddlApplicationRunner");
                }
            }
        };
    }
}


